package cn.edu.gduf.luowowo.scenic.service.impl;

import cn.edu.gduf.luowowo.scenic.domain.ScenicDetial;
import cn.edu.gduf.luowowo.scenic.mapper.ScenicDetialMapper;
import cn.edu.gduf.luowowo.scenic.query.ScenicQuery;
import cn.edu.gduf.luowowo.scenic.service.IScenicDetialService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ScenicDetialServiceImpl implements IScenicDetialService {

    @Autowired
    private ScenicDetialMapper scenicDetialMapper;

    @Override
    public List<ScenicDetial> list() {
        return scenicDetialMapper.selectAll();
    }

    @Override
    public ScenicDetial get(Long id) {
        return scenicDetialMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<ScenicDetial> queryTop5ByScDetialId(Long scId) {
        return scenicDetialMapper.selectTop5ByScDetialId(scId);
    }

    @Override
    public List<ScenicDetial> queryTop10ByScDetialId(Long scId) {
        return scenicDetialMapper.selectTop10ByScDetialId(scId);
    }

    @Override
    public PageInfo query(ScenicQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        return new PageInfo(scenicDetialMapper.selectForList(qo));
    }

    @Override
    public ScenicDetial queryScDetialByDetialId(Long detialId) {
        return scenicDetialMapper.selectScDetialByDetialId(detialId);
    }

    @Override
    public List<ScenicDetial> queryInsideScById(Long id) {
        return scenicDetialMapper.selectInsideScById(id);
    }

    @Override
    public void addFavorNum(Long scId, int num) {
        scenicDetialMapper.updateFavorNumById(scId, num);
    }

    @Override
    public void addBeenNum(Long scid, int num) {
        scenicDetialMapper.updateBeenNumById(scid, num);
    }

    @Override
    public ScenicDetial queryDetailById(Long scenicId) {
        return scenicDetialMapper.selectByPrimaryKey(scenicId);
    }

    @Override
    public ScenicDetial selectByPrimaryKey(Long scId) {
        return scenicDetialMapper.selectByPrimaryKey(scId);
    }
}
